package com.cuitrip.business.location.model;

import com.cuitrip.util.PinYinUtil;

/**
 * Created by baziii on 15/8/19.
 */
public class AreaMode implements Comparable<AreaMode>{
    private String name;
    private String locationId;
    private String abbr;
    private int hasChild;
    private String firstChar;

    public String getFirstChar() {
        return firstChar;
    }

    public void setFirstChar(String firstChar) {
        this.firstChar = firstChar;
    }

    public AreaMode() {
    }

    public AreaMode(String name, String locationId, String abbr) {
        this.name = name;
        this.locationId = locationId;
        this.abbr = abbr;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLocationId() {
        return locationId;
    }

    public void setLocationId(String locationId) {
        this.locationId = locationId;
    }

    public String getAbbr() {
        return abbr;
    }

    public void setAbbr(String abbr) {
        this.abbr = abbr;
    }

    public int getHasChild() {
        return hasChild;
    }

    public void setHasChild(int hasChild) {
        this.hasChild = hasChild;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        AreaMode areaMode = (AreaMode) o;

        if (locationId != null ? !locationId.equals(areaMode.locationId) : areaMode.locationId != null)
            return false;

        return true;
    }

    public static AreaMode getEmptyObject(){
        return new AreaMode("","","");
    }

    @Override
    public int hashCode() {
        return locationId != null ? locationId.hashCode() : 0;
    }

    @Override
    public int compareTo(AreaMode another) {
        if (another==null){
            return 1;
        }
        return PinYinUtil.toPinyin(name).compareTo(PinYinUtil.toPinyin(another.getName()));
    }
}
